package dataAccess;

import java.sql.ResultSet;
import java.sql.SQLException;

import exception.MyException;

import logic.Rate;

public class RateDB {

	public boolean save(Rate rate){
		return true;
	}
	
	public boolean update(Rate rate){
		return true;
	}
	
	public double select() throws MyException{
		double value=0;
		DBManager db;
		try {
			db = new DBManager();
		} catch (MyException e1) {
			throw e1;
		}
		try{			
			String select = "SELECT value FROM imm.rate LIMIT 1";
			ResultSet rs = db.executeAndReturn(select);
			boolean wasnull = rs.wasNull();
			System.out.println(wasnull);
			while (rs.next()){
				value = rs.getDouble("value");
				System.out.println(value);
			}
		}catch (SQLException e){
			throw new MyException("Error de base de datos al recorrer registro");
		}catch (MyException e){
			throw e;
		}finally {
			db.close();
		}
		return value;	
	}
}
